<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Linux 文件内容查看编辑 | 知识库</title>
    <meta name="generator" content="VuePress 1.9.2">
    <link rel="icon" href="/vuepress-theme-vdoing-doc/img/favicon.ico">
    <noscript><meta http-equiv="refresh" content="0; url=https://www.youngkbt.cn/noscript/"><style>.theme-vdoing-content { display:none }</noscript>
    <meta name="description" content="一个基于VuePress的 知识管理">
    <meta name="keywords" content="vuepress,theme,blog,vdoing">
    <meta name="theme-color" content="#11a8cd">
    
    <link rel="preload" href="/vuepress-theme-vdoing-doc/assets/css/0.styles.b0974950.css" as="style"><link rel="preload" href="/vuepress-theme-vdoing-doc/assets/js/app.f061d58b.js" as="script"><link rel="preload" href="/vuepress-theme-vdoing-doc/assets/js/2.9bf30e88.js" as="script"><link rel="preload" href="/vuepress-theme-vdoing-doc/assets/js/72.54e30335.js" as="script"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/10.d2937c56.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/11.67567365.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/12.74e8c324.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/13.2376fcd7.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/14.57ef5c33.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/15.44e7c0ba.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/16.c2fb4c44.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/17.af212389.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/18.1e6acac7.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/19.54653ac9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/20.920cc499.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/21.37128fe3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/22.8f68a2f2.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/23.7b9f1ba6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/24.12adc291.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/25.cfe381e5.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/26.9cf879f6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/27.4e6190ea.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/28.1e22fc79.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/29.c57e047d.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/3.cdcce428.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/30.21a95474.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/31.ce97e6e3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/32.cdb45d73.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/33.fd95e780.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/34.cd49a408.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/35.fe128161.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/36.02043ece.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/37.02eee249.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/38.4650dec6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/39.04fb7652.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/4.c02b1e5f.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/40.7b51f807.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/41.1df513a9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/42.92a82cec.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/43.363fceef.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/44.867b24fd.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/45.89f64bfa.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/46.3a4c53d8.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/47.b8a31c80.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/48.7a584b38.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/49.98345029.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/5.cb45b2c7.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/50.6a0b68f4.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/51.8945cdf6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/52.6583e327.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/53.f6987dfc.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/54.cca012f3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/55.8c58cf5c.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/56.23e08364.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/57.08b54de0.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/58.131ee23e.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/59.45637607.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/6.c97c5dc9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/60.fe9c5dd1.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/61.39ad8fda.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/62.ede47d34.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/63.4bb3e179.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/64.23f955bc.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/65.77ffc240.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/66.a4503c94.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/67.bd3d6fa6.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/68.a003ac59.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/69.64c66f41.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/7.1e88af32.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/70.87dfbf7d.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/71.02806218.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/73.002db3b4.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/74.e577570e.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/75.e610b3c9.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/76.f684a067.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/77.8be17062.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/78.cabc6873.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/79.83febd7c.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/8.91701106.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/80.19e3b7ca.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/81.1b4cafb3.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/82.752ef803.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/83.460cd49b.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/84.377a221f.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/85.016eaf98.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/86.604c5deb.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/87.d3a3662d.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/88.0cf7f581.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/89.40b002bd.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/9.94309dfb.js"><link rel="prefetch" href="/vuepress-theme-vdoing-doc/assets/js/90.086847f8.js">
    <link rel="stylesheet" href="/vuepress-theme-vdoing-doc/assets/css/0.styles.b0974950.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/vuepress-theme-vdoing-doc/" class="home-link router-link-active"><img src="/vuepress-theme-vdoing-doc/img/logo.png" alt="知识库" class="logo"> <span class="site-name can-hide">知识库</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/vuepress-theme-vdoing-doc/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/52d5c3/" class="nav-link">主题初衷与诞生</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="nav-link">介绍</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e08c97/" class="nav-link">模板集</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="案例" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="link-title">案例</a> <span class="title" style="display:none;">案例</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="nav-link">01.后端.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/4bd4c3/" class="nav-link">02.前端.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Docker" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="link-title">Docker</a> <span class="title" style="display:none;">Docker</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="nav-link">Docker安装与卸载</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ceaf16/" class="nav-link">Docker常用命令</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Linux" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/489582/" class="link-title">Linux</a> <span class="title" style="display:none;">Linux</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/489582/" class="nav-link">01.防火墙设置.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="nav-link">02.Linux文件压缩和解压要点.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" class="nav-link">03.Linux 文件目录管理.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/503b98/" aria-current="page" class="nav-link router-link-exact-active router-link-active">04.Linux 文件内容查看编辑.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e7b850/" class="nav-link">05.Linux 网络管理.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="空间聚合" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="link-title">空间聚合</a> <span class="title" style="display:none;">空间聚合</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="nav-link">OGC标准函数</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/fcb182/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>MyBatis</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/01e8a8/" class="nav-link">01.XML 映射器.md</a></li></ul></li><li class="dropdown-item"><h4>国产数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3c4d09/" class="nav-link">01.达梦适配.md</a></li><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3ab660/" class="nav-link">02.瀚高适配.md</a></li></ul></li><li class="dropdown-item"><h4>Selenium爬取数据</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/e110c2/" class="nav-link">spring boot+selenium爬取数据.md</a></li></ul></li></ul></div></div> <a href="https://gitee.com/" target="_blank" rel="noopener noreferrer" class="repo-link">
    Source
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/vuepress-theme-vdoing-doc/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/52d5c3/" class="nav-link">主题初衷与诞生</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a2f161/" class="nav-link">介绍</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e08c97/" class="nav-link">模板集</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="案例" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="link-title">案例</a> <span class="title" style="display:none;">案例</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/5d571c/" class="nav-link">01.后端.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/4bd4c3/" class="nav-link">02.前端.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Docker" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="link-title">Docker</a> <span class="title" style="display:none;">Docker</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/68917f/" class="nav-link">Docker安装与卸载</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ceaf16/" class="nav-link">Docker常用命令</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Linux" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/489582/" class="link-title">Linux</a> <span class="title" style="display:none;">Linux</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/489582/" class="nav-link">01.防火墙设置.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="nav-link">02.Linux文件压缩和解压要点.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" class="nav-link">03.Linux 文件目录管理.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/503b98/" aria-current="page" class="nav-link router-link-exact-active router-link-active">04.Linux 文件内容查看编辑.md</a></li><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/e7b850/" class="nav-link">05.Linux 网络管理.md</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="空间聚合" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="link-title">空间聚合</a> <span class="title" style="display:none;">空间聚合</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vuepress-theme-vdoing-doc/pages/a3137a/" class="nav-link">OGC标准函数</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/vuepress-theme-vdoing-doc/pages/fcb182/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>MyBatis</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/01e8a8/" class="nav-link">01.XML 映射器.md</a></li></ul></li><li class="dropdown-item"><h4>国产数据库</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3c4d09/" class="nav-link">01.达梦适配.md</a></li><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/3ab660/" class="nav-link">02.瀚高适配.md</a></li></ul></li><li class="dropdown-item"><h4>Selenium爬取数据</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vuepress-theme-vdoing-doc/pages/e110c2/" class="nav-link">spring boot+selenium爬取数据.md</a></li></ul></li></ul></div></div> <a href="https://gitee.com/" target="_blank" rel="noopener noreferrer" class="repo-link">
    Source
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <div class="sidebar-slot sidebar-slot-top">
  <a href="http://apifox.cn/a103xugaoyi" target="_blank">
<!--    <img src="https://cdn.staticaly.com/gh/xugaoyi/blog-gitalk-comment@master/img/431669861564_.2470ykdcpbds.jpg" alt="npm" class="no-zoom" style="width: 100%;border-radius: 2px;">-->
<!--    <p style="text-align: center;margin: 0;color: #999;font-size: 12px;">(进入注册为作者充电)</p>-->
  </a></div> <ul class="sidebar-links"><li><a href="/vuepress-theme-vdoing-doc/pages/489582/" class="sidebar-link">防火墙设置</a></li><li><a href="/vuepress-theme-vdoing-doc/pages/6babae/" class="sidebar-link">Linux文件压缩和解压要点</a></li><li><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" class="sidebar-link">Linux 文件目录管理</a></li><li><a href="/vuepress-theme-vdoing-doc/pages/503b98/" aria-current="page" class="active sidebar-link">Linux 文件内容查看编辑</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_1-linux-文件内容查看编辑要点" class="sidebar-link">1. Linux 文件内容查看编辑要点</a></li><li class="sidebar-sub-header level2"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_2-命令常见用法" class="sidebar-link">2. 命令常见用法</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_2-1-cat" class="sidebar-link">2.1. cat</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_2-2-head" class="sidebar-link">2.2. head</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_2-3-tail" class="sidebar-link">2.3. tail</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_2-4-more" class="sidebar-link">2.4. more</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_2-5-less" class="sidebar-link">2.5. less</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_2-6-sed" class="sidebar-link">2.6. sed</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_2-7-vi" class="sidebar-link">2.7. vi</a></li><li class="sidebar-sub-header level3"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_2-8-grep" class="sidebar-link">2.8. grep</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/vuepress-theme-vdoing-doc/pages/503b98/#_3-参考资料" class="sidebar-link">3. 参考资料</a></li></ul></li><li><a href="/vuepress-theme-vdoing-doc/pages/e7b850/" class="sidebar-link">Linux 网络管理</a></li><li><a href="/vuepress-theme-vdoing-doc/pages/c7033b/" class="sidebar-link">系统磁盘扩容</a></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/vuepress-theme-vdoing-doc/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><span data-v-06225672>linux</span></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="https://gitee.com/wenlongjia" target="_blank" title="作者" class="beLink" data-v-06225672>Insist</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-05-25</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">Linux 文件内容查看编辑<!----></h1> <div class="page-slot page-slot-top">
    <div class="wwads-cn wwads-horizontal page-wwads" data-id="136"></div>
    <style>
      .page-wwads{
        width:100%!important;
        min-height: 0;
        margin: 0;
      }
      .page-wwads .wwads-img img{
        width:80px!important;
      }
      .page-wwads .wwads-poweredby{
        width: 40px;
        position: absolute;
        right: 25px;
        bottom: 3px;
      }
      .wwads-content .wwads-text, .page-wwads .wwads-text{
        height: 100%;
        padding-top: 5px;
        display: block;
      }
  </style>
  </div> <div class="theme-vdoing-content content__default"><h1 id="linux-文件内容查看编辑"><a href="#linux-文件内容查看编辑" class="header-anchor">#</a> Linux 文件内容查看编辑</h1> <blockquote><p>关键词：<code>cat</code>, <code>head</code>, <code>tail</code>, <code>more</code>, <code>less</code>, <code>sed</code>, <code>vi</code>, <code>grep</code></p></blockquote> <h2 id="_1-linux-文件内容查看编辑要点"><a href="#_1-linux-文件内容查看编辑要点" class="header-anchor">#</a> 1. Linux 文件内容查看编辑要点</h2> <ul><li>连接文件并打印到标准输出设备 - 使用 <a href="#cat">cat</a></li> <li>显示指定文件的开头若干行 - 使用 <a href="#head">head</a></li> <li>显示指定文件的末尾若干行，常用于实时打印日志文件内容 - 使用 <a href="#tail">tail</a></li> <li>显示文件内容，每次显示一屏 - 使用 <a href="#more">more</a></li> <li>显示文件内容，每次显示一屏 - 使用 <a href="#less">less</a></li> <li>自动编辑一个或多个文件；简化对文件的反复操作；编写转换程序等 - 使用 <a href="#sed">sed</a></li> <li>文本编辑器 - 使用 <a href="#vi">vi</a></li> <li>使用正则表达式搜索文本，并把匹配的行打印出来 - 使用 <a href="#grep">grep</a></li></ul> <h2 id="_2-命令常见用法"><a href="#_2-命令常见用法" class="header-anchor">#</a> 2. 命令常见用法</h2> <h3 id="_2-1-cat"><a href="#_2-1-cat" class="header-anchor">#</a> 2.1. cat</h3> <blockquote><p>cat 命令用于连接文件并打印到标准输出设备上。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">cat</span> m1              <span class="token comment"># 在屏幕上显示文件 ml 的内容</span>
<span class="token function">cat</span> m1 m2           <span class="token comment"># 同时显示文件 ml 和 m2 的内容</span>
<span class="token function">cat</span> m1 m2 <span class="token operator">&gt;</span> <span class="token function">file</span>    <span class="token comment"># 将文件 ml 和 m2 合并后放入文件 file 中</span>
</code></pre></div><h3 id="_2-2-head"><a href="#_2-2-head" class="header-anchor">#</a> 2.2. head</h3> <blockquote><p>head 命令用于显示文件的开头内容。在默认情况下，head 命令显示文件的头部 10 行内容。</p></blockquote> <h3 id="_2-3-tail"><a href="#_2-3-tail" class="header-anchor">#</a> 2.3. tail</h3> <blockquote><p>tail 命令用于显示文件的尾部内容。在默认情况下，tail 命令显示文件的尾部 10 行内容。如果给定的文件不止一个，则在显示的每个文件前面加一个文件名标题。如果没有指定文件或者文件名为“-”，则读取标准输入。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">tail</span> <span class="token function">file</span>           <span class="token comment"># 显示文件file的最后10行</span>
<span class="token function">tail</span> <span class="token parameter variable">-n</span> +20 <span class="token function">file</span>    <span class="token comment"># 显示文件file的内容，从第20行至文件末尾</span>
<span class="token function">tail</span> <span class="token parameter variable">-c</span> <span class="token number">10</span> <span class="token function">file</span>     <span class="token comment"># 显示文件file的最后10个字符</span>
</code></pre></div><h3 id="_2-4-more"><a href="#_2-4-more" class="header-anchor">#</a> 2.4. more</h3> <blockquote><p>more 命令是一个基于 vi 编辑器文本过滤器，它以全屏幕的方式按页显示文本文件的内容，支持 vi 中的关键字定位操作。more 名单中内置了若干快捷键，常用的有 H（获得帮助信息），Enter（向下翻滚一行），空格（向下滚动一屏），Q（退出命令）。</p> <p>该命令一次显示一屏文本，满屏后停下来，并且在屏幕的底部出现一个提示信息，给出至今己显示的该文件的百分比：--More--（XX%）可以用下列不同的方法对提示做出回答：</p> <ul><li>按 Space 键：显示文本的下一屏内容。</li> <li>按 Enier 键：只显示文本的下一行内容。</li> <li>按斜线符|：接着输入一个模式，可以在文本中寻找下一个相匹配的模式。</li> <li>按 H 键：显示帮助屏，该屏上有相关的帮助信息。</li> <li>按 B 键：显示上一屏内容。</li> <li>按 Q 键：退出 rnore 命令。</li></ul></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 显示文件 file 的内容，但在显示之前先清屏，并且在屏幕的最下方显示完核的百分比。</span>
<span class="token function">more</span> <span class="token parameter variable">-dc</span> <span class="token function">file</span>

<span class="token comment"># 显示文件 file 的内容，每 10 行显示一次，而且在显示之前先清屏。</span>
<span class="token function">more</span> <span class="token parameter variable">-c</span> <span class="token parameter variable">-10</span> <span class="token function">file</span>
</code></pre></div><h3 id="_2-5-less"><a href="#_2-5-less" class="header-anchor">#</a> 2.5. less</h3> <p>less 命令的作用与 more 十分相似，都可以用来浏览文字档案的内容，不同的是 less 命令允许用户向前或向后浏览文件，而 more 命令只能向前浏览。用 less 命令显示文件时，用 PageUp 键向上翻页，用 PageDown 键向下翻页。要退出 less 程序，应按 Q 键。</p> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">less</span> /var/log/shadowsocks.log
</code></pre></div><h3 id="_2-6-sed"><a href="#_2-6-sed" class="header-anchor">#</a> 2.6. sed</h3> <blockquote><p>sed 是一种流编辑器，它是文本处理工具，能够完美的配合正则表达式使用，功能不同凡响。处理时，把当前处理的行存储在临时缓冲区中，称为“模式空间”（pattern space），接着用 sed 命令处理缓冲区中的内容，处理完成后，把缓冲区的内容送往屏幕。接着处理下一行，这样不断重复，直到文件末尾。文件内容并没有改变，除非你使用重定向存储输出。Sed 主要用来自动编辑一个或多个文件；简化对文件的反复操作；编写转换程序等。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 替换文本中的字符串</span>
<span class="token function">sed</span> <span class="token string">'s/book/books/'</span> <span class="token function">file</span>

<span class="token comment"># -n 选项 和 p 命令 一起使用表示只打印那些发生替换的行</span>
<span class="token function">sed</span> <span class="token parameter variable">-n</span> <span class="token string">'s/test/TEST/p'</span> <span class="token function">file</span>

<span class="token comment"># 直接编辑文件选项 -i ，会匹配 file 文件中每一行的第一个 book 替换为 books</span>
<span class="token function">sed</span> <span class="token parameter variable">-i</span> <span class="token string">'s/book/books/g'</span> <span class="token function">file</span>

<span class="token comment"># 使用后缀 /g 标记会替换每一行中的所有匹配</span>
<span class="token function">sed</span> <span class="token string">'s/book/books/g'</span> <span class="token function">file</span>

<span class="token comment"># 删除空白行</span>
<span class="token function">sed</span> <span class="token string">'/^$/d'</span> <span class="token function">file</span>

<span class="token comment"># 删除文件的第2行</span>
<span class="token function">sed</span> <span class="token string">'2d'</span> <span class="token function">file</span>

<span class="token comment"># 删除文件的第2行到末尾所有行</span>
<span class="token function">sed</span> <span class="token string">'2,$d'</span> <span class="token function">file</span>

<span class="token comment"># 删除文件最后一行</span>
<span class="token function">sed</span> <span class="token string">'$d'</span> <span class="token function">file</span>

<span class="token comment"># 删除文件中所有开头是test的行</span>
<span class="token function">sed</span> <span class="token string">'/^test/'</span>d <span class="token function">file</span>
</code></pre></div><h3 id="_2-7-vi"><a href="#_2-7-vi" class="header-anchor">#</a> 2.7. vi</h3> <blockquote><p>vi 命令是 UNIX 操作系统和类 UNIX 操作系统中最通用的全屏幕纯文本编辑器。Linux 中的 vi 编辑器叫 vim，它是 vi 的增强版（vi Improved），与 vi 编辑器完全兼容，而且实现了很多增强功能。</p> <p>引申阅读：<a href="https://github.com/dunwu/OS/blob/master/docs/vim.md" target="_blank" rel="noopener noreferrer">Vim 入门指南<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></blockquote> <h3 id="_2-8-grep"><a href="#_2-8-grep" class="header-anchor">#</a> 2.8. grep</h3> <blockquote><p>grep（global search regular expression(RE) and print out the line，全面搜索正则表达式并把行打印出来）是一种强大的文本搜索工具，它能使用正则表达式搜索文本，并把匹配的行打印出来。</p></blockquote> <p>示例：</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 在多级目录中对文本递归搜索(程序员搜代码的最爱）:</span>
$ <span class="token function">grep</span> <span class="token string">&quot;class&quot;</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-R</span> <span class="token parameter variable">-n</span>

<span class="token comment"># 忽略匹配样式中的字符大小写</span>
$ <span class="token builtin class-name">echo</span> <span class="token string">&quot;hello world&quot;</span> <span class="token operator">|</span> <span class="token function">grep</span> <span class="token parameter variable">-i</span> <span class="token string">&quot;HELLO&quot;</span>

<span class="token comment"># 匹配多个模式:</span>
$ <span class="token function">grep</span> <span class="token parameter variable">-e</span> <span class="token string">&quot;class&quot;</span> <span class="token parameter variable">-e</span> <span class="token string">&quot;vitural&quot;</span> <span class="token function">file</span>

<span class="token comment"># 只在目录中所有的.php和.html文件中递归搜索字符&quot;main()&quot;</span>
$ <span class="token function">grep</span> <span class="token string">&quot;main()&quot;</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-r</span> <span class="token parameter variable">--include</span> *.<span class="token punctuation">{</span>php,html<span class="token punctuation">}</span>

<span class="token comment"># 在搜索结果中排除所有README文件</span>
$ <span class="token function">grep</span> <span class="token string">&quot;main()&quot;</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-r</span> <span class="token parameter variable">--exclude</span> <span class="token string">&quot;README&quot;</span>

<span class="token comment"># 在搜索结果中排除filelist文件列表里的文件</span>
$ <span class="token function">grep</span> <span class="token string">&quot;main()&quot;</span> <span class="token builtin class-name">.</span> <span class="token parameter variable">-r</span> --exclude-from filelist
</code></pre></div><h2 id="_3-参考资料"><a href="#_3-参考资料" class="header-anchor">#</a> 3. 参考资料</h2></div></div>  <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2023/08/14, 13:28:01</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">Linux 文件目录管理</div></a> <a href="/vuepress-theme-vdoing-doc/pages/e7b850/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">Linux 网络管理</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/vuepress-theme-vdoing-doc/pages/ccdc52/" class="prev">Linux 文件目录管理</a></span> <span class="next"><a href="/vuepress-theme-vdoing-doc/pages/e7b850/">Linux 网络管理</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><div class="icons"></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2023-2024
    <span>Insist | MIT License</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/vuepress-theme-vdoing-doc/assets/js/app.f061d58b.js" defer></script><script src="/vuepress-theme-vdoing-doc/assets/js/2.9bf30e88.js" defer></script><script src="/vuepress-theme-vdoing-doc/assets/js/72.54e30335.js" defer></script>
  </body>
</html>
